home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / share / tix4.1 / demos / samples / AllSampl.tcl next >
Encoding:
Text File  |  1998-12-04  |  4.4 KB  |  194 lines

  1. # AllSampl.tcl --
  2. #
  3. #    This file is a directory of all the sample programs in the
  4. #    demos/samples subdirectory.
  5. #
  6. #
  7. # Copyright (c) 1996, Expert Interface Technologies
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12. #
  13.  
  14. # The following data structures contains information about the requirements
  15. # of the sample programs, as well as the relationship/grouping of the sample
  16. # programs.
  17. #
  18. # Each element in an info list has four parts: type, name, group/filename, and
  19. # condition. A group or a file is loaded only if the conditions are met.
  20. #
  21. # types: "d" directory "f" file
  22. # conditions:
  23. #    "i":    an image type must exist
  24. #    "c":    a command must exist
  25. #    "v":     a variable must exist
  26.  
  27. set root {
  28.     {d "File Selectors"        file    }
  29.     {d "Hierachical ListBox"    hlist    }
  30.     {d "Tabular ListBox"    tlist    {c tixTList}}
  31.     {d "Grid Widget"        grid    {c tixGrid}}
  32.     {d "Manager Widgets"    manager    }
  33.     {d "Scrolled Widgets"    scroll    }
  34.     {d "Miscellaneous Widgets"    misc    }
  35.     {d "Image Types"        image    }
  36. }
  37.  
  38. set image {
  39.     {d "Compound Image"        cmpimg    }
  40.     {d "XPM Image"        xpm    {i pixmap}}
  41. }
  42.  
  43. set cmpimg {
  44.     {f "In Buttons"        CmpImg.tcl    }
  45.     {f "In NoteBook"        CmpImg2.tcl    }
  46.     {f "Notebook Color Tabs"    CmpImg4.tcl    }
  47.     {f "Icons"            CmpImg3.tcl    }
  48. }
  49.  
  50. set xpm {
  51.     {f "In Button"        Xpm.tcl        {i pixmap}}
  52.     {f "In Menu"        Xpm1.tcl    {i pixmap}}
  53. }
  54.  
  55. set file {
  56.     {f DirList                DirList.tcl    }
  57.     {f DirTree                DirTree.tcl    }
  58.     {f DirSelectDialog            DirDlg.tcl    }
  59.     {f ExFileSelectDialog        EFileDlg.tcl    }
  60.     {f FileSelectDialog            FileDlg.tcl    }
  61.     {f FileEntry            FileEnt.tcl    }
  62. }
  63.  
  64. set hlist {
  65.     {f HList            HList1.tcl    }
  66.     {f CheckList        ChkList.tcl    {c tixCheckList}}
  67.     {f "ScrolledHList (1)"    SHList.tcl    }
  68.     {f "ScrolledHList (2)"    SHList2.tcl    }
  69.     {f Tree            Tree.tcl    }
  70.     {f "Tree (Dynamic)"        DynTree.tcl    {v win}}
  71. }
  72.  
  73. set tlist {
  74.     {f "ScrolledTList (1)"    STList1.tcl    {c tixTList}}
  75.     {f "ScrolledTList (2)"    STList2.tcl    {c tixTList}}
  76.     {f "TList File Viewer"    STList3.tcl    {c tixTList}}
  77. }
  78.  
  79. set grid {
  80.     {f "Simple Grid"        SGrid0.tcl    {c tixGrid}}
  81.     {f "ScrolledGrid"        SGrid1.tcl    {c tixGrid}}
  82.     {f "Editable Grid"        EditGrid.tcl    {c tixGrid}}
  83. }
  84.  
  85. set scroll {
  86.     {f ScrolledListBox        SListBox.tcl    }
  87.     {f ScrolledText        SText.tcl    }
  88.     {f ScrolledWindow        SWindow.tcl    }
  89.     {f "Canvas Object View"    CObjView.tcl    {c tixCObjView}}
  90. }
  91.  
  92. set manager {
  93.     {f ListNoteBook        ListNBK.tcl    }
  94.     {f NoteBook            NoteBook.tcl    }
  95.     {f PanedWindow        PanedWin.tcl    }
  96. }
  97.  
  98. set misc {
  99.     {f Balloon            Balloon.tcl    }
  100.     {f ButtonBox        BtnBox.tcl    }
  101.     {f ComboBox            ComboBox.tcl    }
  102.     {f Control            Control.tcl    }
  103.     {f LabelEntry        LabEntry.tcl    }
  104.     {f LabelFrame        LabFrame.tcl    }
  105.     {f Meter            Meter.tcl    {c tixMeter}}
  106.     {f OptionMenu        OptMenu.tcl    }
  107.     {f PopupMenu        PopMenu.tcl    }
  108.     {f Select            Select.tcl    }
  109.     {f StdButtonBox        StdBBox.tcl    }
  110. }
  111.  
  112. # ForAllSamples --
  113. #
  114. #    Iterates over all the samples that can be run on this platform.
  115. #
  116. # Arguments:
  117. #    name:        For outside callers, it must be "root"
  118. #    token:        An arbtrary string passed in by the caller.
  119. #    command:    Command prefix to be executed for each node
  120. #            in the samples hierarchy. It should return the
  121. #            token of the node that it has just created, if any.
  122. #
  123. proc ForAllSamples {name token command} {
  124.     global $name win
  125.  
  126.     if {[tix platform] == "windows"} {
  127.     set win 1
  128.     }
  129.  
  130.     foreach line [set $name] {
  131.     set type [lindex $line 0]
  132.     set text [lindex $line 1]
  133.     set dest [lindex $line 2]
  134.     set cond [lindex $line 3]
  135.  
  136.     case [lindex $cond 0] {
  137.         c {
  138.         set cmd [lindex $cond 1]
  139.         if {[info command $cmd] != $cmd} {
  140.             if ![auto_load $cmd] {
  141.             continue
  142.             }
  143.         }
  144.         }
  145.         i {
  146.         if {[lsearch [image types] [lindex $cond 1]] == -1} {
  147.             continue
  148.         }
  149.         }
  150.         v {
  151.         set doit 1
  152.         foreach var [lrange $cond 1 end] {
  153.             if [uplevel #0 info exists [list $var]] {
  154.             set doit 0
  155.             break
  156.             }
  157.         }
  158.         if !$doit {
  159.             continue
  160.         }
  161.         }
  162.     }
  163.  
  164.  
  165.     if {$type == "d"} {
  166.         set tok [eval $command [list $token] $type [list $text] \
  167.             [list $dest]]
  168.         ForAllSamples $dest $tok $command
  169.         eval $command [list $tok] done xx xx
  170.     } else {
  171.         set tok [eval $command [list $token] $type [list $text] \
  172.         [list $dest]]
  173.     }
  174.     }
  175. }
  176.  
  177.  
  178. proc DoAll {hlist {path ""}} {
  179.     catch {
  180.     set theSample [$hlist info data $path]
  181.     if {$theSample != {}} {
  182.         set title [lindex $theSample 0]
  183.         set prog  [lindex $theSample 1]
  184.  
  185.         RunProg $title $prog
  186.        update
  187.     }
  188.     }
  189.  
  190.     foreach p [$hlist info children $path] {
  191.     DoAll $hlist $p
  192.     }    
  193. }
  194.